<!DOCTYPE html>
<html>
<head>
    <title>百度地图demo</title>
    <meta charset="utf-8"/>
    <script src="../lib/jquery-1.8.2.min.js"></script>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=zPomu03g9CYLBHLchS1NjlK5"></script>
    <script src="http://res.xiami.net/pc/lay/lib.js"></script>
    <script src="http://res.sentsin.com/lay/lib/laycode/laycode.min.js"></script>

    <style>
        body{
            width:100%;
            height: 100%;
            margin: 0px;
            padding:0px;
        }
        #map{
            width:100%;
            float: left;
        }
    </style>
</head>
<body>
    <div id="map"></div>
    <script>
        (function(){
            $("#map").css("height",window.screen.availHeight);
            var map = new BMap.Map("map");
            map.centerAndZoom(new BMap.Point(116.404, 39.915), 14);
            var navigationControl = new BMap.NavigationControl({
                // 靠左上角位置
                anchor: BMAP_ANCHOR_TOP_LEFT,
                // LARGE类型
                type: BMAP_NAVIGATION_CONTROL_LARGE,
                // 启用显示定位
                enableGeolocation: true
            });
            map.addControl(navigationControl);
            var myGeo = new BMap.Geocoder();
            // 将地址解析结果显示在地图上,并调整地图视野
            var address = "北京市海淀区上地10街";
            myGeo.getPoint(address, function(point){
                if (point) {
                    map.centerAndZoom(point, 16);
                    var marker = new BMap.Marker(point);
                    map.addOverlay(marker);
                    marker.setLabel(new BMap.Label(address,{offset:new BMap.Size(20,10)}));
                    var html="<font style='color:red;font-size:15px;'>"+address+"</font>";
                    var opts = {
                        width : 200,     // 信息窗口宽度
                        title : html // 信息窗口标题
                    }
                    var infoWindow = new BMap.InfoWindow("<br/><font style='font-size:12px;'>地址："+address+"</font>", opts);  // 创建信息窗口对象
                    marker.addEventListener("click", function(){
                        map.openInfoWindow(infoWindow,point); //开启信息窗口
                    });
                }else{
                    alert("您选择地址没有解析到结果!");
                }
            }, "北京市");
            map.enableScrollWheelZoom();   //启用滚轮放大缩小，默认禁用
            map.enableContinuousZoom();    //启用地图惯性拖拽，默认禁用

            setTimeout("a()",3000);
        })();

    </script>
</body>
</html>